package cn.tedu.spring2205.week01.demo01.config;

import cn.tedu.spring2205.week01.demo01.dao.PersonDao;
import cn.tedu.spring2205.week01.demo01.dao.StudentDao;
import cn.tedu.spring2205.week01.demo01.dao.UserDao;
import cn.tedu.spring2205.week01.demo01.dao.impl.PersonDaoImpl;
import cn.tedu.spring2205.week01.demo01.dao.impl.StudentDaoImpl;
import cn.tedu.spring2205.week01.demo01.dao.impl.StudentDaoImpl1;
import cn.tedu.spring2205.week01.demo01.service.PersonService;
import cn.tedu.spring2205.week01.demo01.service.impl.PersonServiceImpl;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.Scope;

/**
 * @Configuration 表明该类为配置类
 * 在配置类中就可以定义Bean
 */
@Configuration
@ComponentScan("cn.tedu.spring2205.week01.demo01")
public class MyConfig {

    @Bean
    @Scope("prototype")
    public UserDao userDao(){
        return new UserDao();
    }

    @Bean
    public StudentDao studentDao(){
        return new StudentDaoImpl();
    }

    @Bean
    public StudentDao studentDao1(){
        return new StudentDaoImpl1();
    }

    @Bean
    public PersonDao personDao(){
        return new PersonDaoImpl();
    }

    @Bean
    public PersonService personService(PersonDao personDao){
        return new PersonServiceImpl(personDao);
    }

}
